define(['jquery'],function($){
    function login(){
        $('.agree').click(function(){
            if($('.agree').prop('checked')){
                $('.submit_id').css('cursor','pointer')
            }else{
                $('.submit_id').css('cursor','not-allowed')
            }
        })
        $('.submit_id').click(function(){
            if($('.agree').prop('checked')){
                $.ajax({
                    type:'post',
                    url:'../php/login.php',
                    data:{
                        username:$('.username').val(),
                        passward:$('.passward').val(),
                        createTime:(new Date()).getTime()
                    },
                    success:function(result){
                        var obj=JSON.parse(result)
                        $('.hint').html(obj.message).css('color','red')
                        if(obj.code>=6){
                            $('.hint').html(obj.message).css('color','blue')
                            setTimeout(function(){
                                window.location.assign('../index.html')
                            },1000)
                        }
                    },
                    error:function(msg){
                        console.log(msg)
                    }
                })
            }else{
                $('.hint').html('请阅读条款')
            }
        })
    }

    return {
        login
    }
})